/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package learnjava.googe.doc;

import com.google.gdata.data.docs.DocumentListEntry;
import java.io.File;

/**
 *
 * @author xddai
 */
public class TestGoogleDoc {

    public static void main(String[] args) {
        GoogleDoc googleDoc = new GoogleDoc("email", "password");
//        for (DocumentListEntry docEntry : googleDoc.getFolders()) {
//            System.out.print(docEntry.getTitle().getPlainText()+":");
//            List<Link> links = docEntry.getParentLinks();
//            for (Link link : links) {
//                System.out.print(">"+link.getTitle());
//            }
//            System.out.println("\n--------------------------------");
//        }
        File rootDir = new File("C:/PDFBook");
        try {
            for (File folder : rootDir.listFiles()) {
                DocumentListEntry folderEntry = googleDoc.getFolder(folder.getName());
                if (folderEntry == null) {
                    folderEntry = googleDoc.createFolder(folder.getName(), "PDFBook");
                }
                for (File file : folder.listFiles()) {
                    if (!googleDoc.hasFile(file)) {
                        googleDoc.uploadFile(file, folderEntry);
                        System.out.println(file.getName());
                    }
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
